package com.mrzhou.common.enums;

import com.mrzhou.core.enums.BaseCodeEnum;
import com.mrzhou.core.tool.utils.EnumUtil;

/**
 * 邮箱或者手机验证码类型
 */
public enum MailPhoneType implements BaseCodeEnum<Integer, String> {

    REGISTER(1, "注册"),

    LOGIN(2, "登录"),

    FORGET(3, "忘记密码"),

    RESET(4, "重置密码")

    ;

    // 类型码
    private Integer code;
    // 描述
    private String des;

    MailPhoneType(Integer code, String des) {
        this.code = code;
        this.des = des;
    }

    public Integer code() {
        return this.code;
    }

    public String des() {
        return this.des;
    }

    /**
     * 将code解析为枚举类, 不存在的code返回null
     * @param code
     * @return
     */
    public static MailPhoneType valueOf(Integer code) {
        return EnumUtil.getEnumByCode(code, MailPhoneType.class);
    }

}
